<template>
    <div v-if="isShow === 1">
        <div class="result" v-for="(item, index) in list" :key="index">
            <img class="frontover" :src="item.albumInfo.cover_path">
            <div class="info">
                <div class="bookTitle">{{ item.albumInfo.title }}</div>
                <div class="summarize">{{ item.albumInfo.intro }}</div>
                <div class="data">
                    <div class="data-1">
                        <van-icon name="user-o" />
                        <div class="shuju">{{ item.albumInfo.nickname }}</div>
                    </div>
                    <div class="data-1">
                        <el-icon>
                            <Service />
                        </el-icon>
                        <div class="shuju">{{ item.albumInfo.tracks }}</div>
                    </div>
                    <div class="data-1">
                        <el-icon>
                            <Headset />
                        </el-icon>
                        <div class="shuju">{{ jinzi(item.albumInfo.play) }}</div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div v-else-if="isShow === 0">
        <div class="result sy" v-for="(item, index) in list" :key="index">
            <div class="tx">
                <img class="frontover cir" :src="item.trackInfo.album_cover_path">
                <div class="mb">
                    <el-icon class="kg" size="30px" color="#fff">
                        <CaretRight />
                    </el-icon>
                </div>
            </div>

            <div class="info">
                <div class="bookTitle">{{ item.trackInfo.title }}</div>
                <div class="data">
                    <div class="data-1">
                        <van-icon name="user-o" />
                        <div class="shuju">{{ item.trackInfo.nickname }}</div>
                    </div>
                    <div class="data-1">
                        <el-icon>
                            <PieChart />
                        </el-icon>
                        <div class="shuju">{{ item.trackInfo.count_comment }}</div>
                    </div>
                    <div class="data-1">
                        <el-icon color="#000">
                            <CaretRight />
                        </el-icon>
                        <div class="shuju">{{ jinzi(item.trackInfo.count_play) }}</div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div v-else>
        <div class="result" v-for="(item, index) in list" :key="index">
            <img class="frontover cir" :src="item.userInfo.smallPic">
            <div class="info">
                <div class="bookTitle ">{{ item.userInfo.nickname }}</div>
                <div class="summarize">{{ item.userInfo.personDescribe }}</div>
                <div class="data">
                    <div class="data-1">
                        <el-icon>
                            <VideoCamera />
                        </el-icon>
                        <div class="shuju">{{ item.userInfo.tracks_counts }}</div>
                    </div>
                    <div class="data-1">
                        <el-icon>
                            <VideoPause />
                        </el-icon>
                        <div class="shuju">{{ item.userInfo.followers_counts }}</div>
                    </div>
                    <div class="data-1">
                        <el-icon>
                            <User />
                        </el-icon>
                        <div class="shuju">{{ jinzi(item.userInfo.followers_counts) }}</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { Service, Headset, CaretRight, PieChart, User, VideoPause, VideoCamera } from '@element-plus/icons-vue'

defineProps < {list: listModel[], isShow: number}> ()

interface albumInfoModel {
    title: string,
    intro: string,
    nickname: string,
    tracks: number,
    play: number,
    cover_path: string,
}

export interface trackInfoModel {
    album_cover_path: string, 
    title: string, 
    nickname: string, 
    count_comment: string, 
    count_play: number
}

export interface userInfoModel {
    smallPic: string, 
    nickname: string,
    personDescribe: string,
    tracks_counts: string,
    followers_counts: number,
}

export interface listModel {
    albumInfo: albumInfoModel;
    pageUriInfo: any;

    trackInfo: trackInfoModel;

    userInfo: userInfoModel;

}

const jinzi = (num: number) => {
    // 10000 ->万
    // 1000 0000 0000 ->亿
    let r;
    if (num >= 10000 && num < 100000000) {
        r = (num / 10000).toFixed(2) + "万";
    } else if (num >= 100000000) {
        r = (num / 100000000).toFixed(2) + "亿";
    } else {
        r = num;
    }
    return r;
}

</script>

<style scoped lang="scss">
.result {
    display: flex;
    border-bottom: 1px solid #eee;
    padding: 10px 5px;



    .frontover {
        width: 70px;
        height: 70px;
        margin-right: 10px;
    }

    .frontover.cir {
        border-radius: 50%;
        width: 70px;
        height: 70px;
        margin-right: 10px;
    }

    .info {
        width: 250px;

        .bookTitle {
            font-size: 16px
        }

        .summarize {
            font-size: 9px;
            margin: 5px 0 10px 0;


            display: -webkit-box;
            -webkit-line-clamp: 4;
            -webkit-box-orient: vertical;
            overflow: hidden;

        }

        .data {
            display: flex;
            font-size: 10px;
            height: 10px;

            .data-1 {
                margin-right: 20px;
                display: flex;
                align-items: center;

                .shuju {
                    margin-left: 5px;
                }
            }
        }
    }
}

.result.sy {
    .tx {
        position: relative;

        .mb {
            position: absolute;
            border: 1px solid #000;
            width: 67px;
            height: 67px;
            border-radius: 50%;
            background-color: #000;
            opacity: .4;
            top: 0;
            left: 0;

            .kg {
                position: absolute;
                top: 18px;
                left: 18px;
            }

        }
    }

    .info {
        margin-top: 10px;

        .bookTitle {
            margin-bottom: 10px;
        }
    }
}
</style>